package com.dataseek.iot.device.controller;

import com.dataseek.iot.device.entity.Profile;
import com.dataseek.iot.device.service.ProfileService;
import com.dataseek.iot.toolikit.common.enums.RspStatusEnum;
import com.dataseek.iot.toolikit.common.response.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("**/profile")
public class ProfileController {

    @Autowired
    private ProfileService profileService;
    

    @RequestMapping(value = "/qryByUserId", method = RequestMethod.GET)
    public ResponseResult qryByUserId(@RequestParam(value="userId", required=true) String userId) throws IOException {
        return new ResponseResult(RspStatusEnum.SUCCESS.getCode(),"成功", profileService.qryByUserId(userId));
    }


    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public ResponseResult insert(@RequestBody Profile profile) throws IOException {
        profileService.insertAction(profile);
        return new ResponseResult(RspStatusEnum.SUCCESS.getCode(),"成功!", 0);
    }

}
